package ZRH;

public class zrh07 {
    public static void main(String[] args) {
        //定义数组
        int[] arr = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        //调用方法
        change(arr, 0);
        //遍历打印
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    /**
     * 遍历数组
     * 从中挑取偶数项
     * 将其赋值为所给的m
     * 返回新数组
     */
    public static int[] change(int[] arr, int m) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0) {
                arr[i] = m;
            }
        }
        return arr;
    }
}
